<?php
namespace addon\mall\validate;
use app\common\validate\ValidateBase;
use think\Db;
class Goods extends ValidateBase
{
    // 验证规则
    protected $rule = [
        'goods_name'                   => 'require|unique:Goods',
        'category_id'                  => 'require|gt:0'
    ];

    // 验证提示
    protected $message = [
        'goods_name.require'             => '商品名称不能为空',
        'goods_name.unique'              => '该商品名称已经存在',
        'category_id.gt'                 => '请选择商品分类'
    ];

    // 应用场景
    protected $scene = [
        'add'=>['goods_name','category_id'],
    ];
}